//  [9/24/2013 OMEGA] created

#include <QtWidgets/QWidget>
#include "DuelAssEContentView.h"
#include "DuelAssEContentManager.h"
#include "DuelAssEContentItem.h"
#include "flowlayout.h"


DAssEContentFlowViewItem::DAssEContentFlowViewItem( DAssEContentFlowView* parent ) : 
	QToolButton(parent), 
	mParent(parent)
{
	setAutoRaise(true);
}

DAssEContentFlowView::DAssEContentFlowView( DAssEContentManager* parent ) : 
	DAssEContentView(parent),
	mLayout(this)
{
	mLayout.setMargin(0);
	setLayout(&mLayout);
}

DAssEContentFlowView::~DAssEContentFlowView()
{
	clear();
}

void DAssEContentFlowView::clear()
{
	qDeleteAll(mPresentItems);
	mPresentItems.clear();
}

void DAssEContentFlowView::displayItems( const ContentItemList& list )
{
	foreach(DAssEContentItem* itm, list)
	{
		DAssEContentFlowViewItem* viewItem = createFlowItem(itm);
		mLayout.addWidget(viewItem);
		mPresentItems.push_back(viewItem);
	}

}

DAssEContentFlowViewItem* DAssEContentFlowView::createFlowItem( DAssEContentItem* srcItm )
{
	DAssEContentFlowViewItem* ret = new DAssEContentFlowViewItem(this);
	ret->setText(srcItm->targetResourceName);
	return ret;
}
